#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main() {
    int num;
    while (~scanf("%d", &num)) {
        if (num == 1) { printf("0\n"); break; }
        int count = 0;
        for (int i = 2; i <= num; i++) {
            int sum = 1, root = sqrt(i);
            for (int j = 2; j <= root; j++) {
                if (i % j == 0) {
                    sum += j;
                    if (i != root)
                        sum += (i / j);
                }
            }
            if (sum == i)count++;
        }
        printf("%d\n", count);
    }
}